package com.cf.studiomanage.mapper;

import com.cf.studiomanage.entity.ClubApplication;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClubApplicationMapper {

    @Insert("INSERT INTO club_application(user_id, type, reason, attachment_url, status) " +
            "VALUES(#{userId}, #{type}, #{reason}, #{attachmentUrl}, 'PENDING')")
    int submitApplication(ClubApplication application);

    @Select("SELECT * FROM club_application WHERE user_id = #{userId} ORDER BY created_at DESC")
    List<ClubApplication> getUserApplications(Long userId);

    @Select("SELECT * FROM club_application ORDER BY created_at DESC")
    List<ClubApplication> getAllApplications();

    @Update("UPDATE club_application SET status = #{status} WHERE id = #{id}")
    int updateStatus(@Param("id") Long id, @Param("status") String status);
}
